See annotated K20P64M72SF1RM manual (MK20DX128 processor used on Teensy 3.1/3.2).
Functional description of Programmable Delay Block (PDB) on page 761.
Page 753.
LDMOD: Load mode select (2 bits)PDBEIE: PDB Sequence error interrupt enableSWTRIG: Software trigger, reset and restart counter if software trigger set as inputDMAEN: DMA enable. 1: PDBIF flag generates a DMA request instead of an interrupt.PRESCALER: Prescaler divider select (3 bits)TRGSEL: Trigger input select (4 bits)SWTRIG)PDBEN: PDB enablePDBIF: PDB interrupt flag, set when counter value is equal to the IDLY register. Writing zero clears this bit.PDBIE: PDB interrupt enable, when this bit is set and DMAEN is cleared, PDBIF generates a PDB interrupt.MULT: Multiplication Factor Select for Prescaler (2 bits), MULT for PRESCALERCONT: Continuous mode enableLDOK: Load OK, update internal registers of MOD, IDLY, CHnDLYm, DACINTx, and POyDLY according to LDMOD scheme.TRGSEL = 15 (Software trigger)PDBEN = 1PDBIE = 1CONT = 1LDMOD = 0PRESCALER = based on frequencyMULT = based on frequencyUse SWTRIG to start first count. Counter continues to loop due to continuous mode (CONT=1).
Page 755.
MOD: PDB modulus (16 bits), specifies the period of the counter.MOD = based on frequencySet to (F_BUS / frequency) - 1, unless (F_BUS / frequency) cannot fit in 16 bits.
In that case, first use SC[MULT] and SC[PRESCALER] to get close to the requested
period, then further divide (F_BUS / frequency) accordingly.
Page 756.
IDLY: PDB Interrupt delay (16 bits), delay value to schedule the PDB interrupt.IDLYIDLY = 1: i.e., the pdb interrupt when CNT = 1.Page 757. One bit per channel.
TODO How manny PDB channels on Teensy 3.1 controller?
BB: PDB Channel Pre-Trigger Back-to-Back Operation Enable (8 bits)TOS: PDB Channel Pre-Trigger Output Select (8 bits)IDLY and one clock cycle after
rising edge on trigger input.EN: PDB Channel Pre-Trigger Enable (8 bits)Assert pre-trigger when counter reaches IDLY (1) and after trigger (software in this case).
TOS = 1EN = 1Page 759.
EXT: DAC External Trigger Input EnableTOE: DAC Interval Trigger Enable